package com.xialuo.study.std;

import org.bsc.langgraph4j.serializer.Serializer;
import org.springframework.ai.chat.messages.UserMessage;

import java.io.IOException;
import java.io.ObjectInput;
import java.io.ObjectOutput;


public class UserMessageSerializer implements Serializer<UserMessage> {

    @Override
    public void write(UserMessage object, ObjectOutput out) throws IOException {
        out.writeUTF(object.getText());
    }


    @Override
    public UserMessage read(ObjectInput in) throws IOException, ClassNotFoundException {
        String text = in.readUTF();
        return new UserMessage(text);
    }
}
